<?php
//NV010207
/*--------KHAIBAO-------------*/
define("DATAFOLD","includes/data");
/*------------END----------------*/
define("NV_SYSTEM", TRUE);
//END

require_once(str_replace('\\\\','/',dirname(__FILE__)).'/../class/config.class.php');
require_once(str_replace('\\\\','/',dirname(__FILE__)).'/../class/util.class.php');

// sets physical filesystem directory of web site root
// if calculation fails (usually if web server is not apache) set this manually
SpawConfig::setStaticConfigItem('DOCUMENT_ROOT', str_replace("\\","/",SpawVars::getServerVar("DOCUMENT_ROOT")));
if (!ereg('/$', SpawConfig::getStaticConfigValue('DOCUMENT_ROOT')))
  SpawConfig::setStaticConfigItem('DOCUMENT_ROOT', SpawConfig::getStaticConfigValue('DOCUMENT_ROOT').'/');
// sets physical filesystem directory where spaw files reside
// should work fine most of the time but if it fails set SPAW_ROOT manually by providing correct path
SpawConfig::setStaticConfigItem('SPAW_ROOT', str_replace("\\","/",realpath(dirname(__FILE__)."/..").'/'));
// sets virtual path to the spaw directory on the server
// if calculation fails set this manually
SpawConfig::setStaticConfigItem('SPAW_DIR', '/'.str_replace(SpawConfig::getStaticConfigValue("DOCUMENT_ROOT"),'',SpawConfig::getStaticConfigValue("SPAW_ROOT")));

//NV010207
SpawConfig::setStaticConfigItem('SPAW_UPLOAD', '/'.str_replace(SpawConfig::getStaticConfigValue("DOCUMENT_ROOT"),'',str_replace("\\","/",realpath(dirname(__FILE__)."/../../..").'/')));
include(str_replace("\\","/",realpath(dirname(__FILE__)."/../../..").'/') . DATAFOLD . '/config_Editor.php');
SpawConfig::setStaticConfigItem('SPAW_PASS', $editorconfig['editor_pass']);
//END
/*
// under IIS you will probably need to setup the above paths manually. it would be something like this
SpawConfig::setStaticConfigItem('DOCUMENT_ROOT', 'c:/inetpub/wwwroot/');
SpawConfig::setStaticConfigItem('SPAW_ROOT', 'c:/inetpub/wwwroot/spaw2/');
SpawConfig::setStaticConfigItem('SPAW_DIR', '/spaw2/');
*/

// DEFAULTS used when no value is set from code
// language 
SpawConfig::setStaticConfigItem('default_lang','en');
// output charset (empty strings means charset specified in language file)
SpawConfig::setStaticConfigItem('default_output_charset','');
// theme 
SpawConfig::setStaticConfigItem('default_theme',"".$editorconfig['default_theme']."");
// toolbarset 
SpawConfig::setStaticConfigItem('default_toolbarset',$editorconfig['default_toolbarset']);
// stylesheet
SpawConfig::setStaticConfigItem('default_stylesheet',SpawConfig::getStaticConfigValue('SPAW_DIR').'wysiwyg.css');
// width 
SpawConfig::setStaticConfigItem('default_width','100%');
// height 
SpawConfig::setStaticConfigItem('default_height','200px');

// specifies if language subsystem should use iconv functions to convert strings to the specified charset
SpawConfig::setStaticConfigItem('USE_ICONV',true);
// specifies rendering mode to use: "xhtml" - renders using spaw's engine, "builtin" - renders using browsers engine
SpawConfig::setStaticConfigItem('rendering_mode', 'xhtml', SPAW_CFG_TRANSFER_JS);
// specifies that xhtml rendering engine should indent it's output
SpawConfig::setStaticConfigItem('beautify_xhtml_output', true, SPAW_CFG_TRANSFER_JS);
// specifies host and protocol part (like http://mydomain.com) that should be added to urls returned from file manager (and probably other places in the future) 
SpawConfig::setStaticConfigItem('base_href', '', SPAW_CFG_TRANSFER_JS);
// specifies if spaw should strip domain part from absolute urls (IE makes all links absolute)
SpawConfig::setStaticConfigItem('strip_absolute_urls', true, SPAW_CFG_TRANSFER_JS);
// specifies in which directions resizing is allowed (values: none, horizontal, vertical, both)
SpawConfig::setStaticConfigItem('resizing_directions', 'vertical', SPAW_CFG_TRANSFER_JS);

// data for style (css class) dropdown list
SpawConfig::setStaticConfigItem("dropdown_data_core_style",
  array(
    '' => 'Normal',
    'style1' => 'Style No.1',
    'style2' => 'Style No.2',
  )
);
// data for style (css class) dropdown in table properties dialog
SpawConfig::setStaticConfigItem("table_styles",
  array(
    '' => 'Normal',
    'style1' => 'Style No.1',
    'style2' => 'Style No.2',
  )
);
// data for fonts dropdown list
SpawConfig::setStaticConfigItem("dropdown_data_core_fontname",
  array(
    'Arial' => 'Arial',
    'Courier' => 'Courier',
    'Tahoma' => 'Tahoma',
    'Times New Roman' => 'Times',
    'Verdana' => 'Verdana'
  )
);
// data for fontsize dropdown list
SpawConfig::setStaticConfigItem("dropdown_data_core_fontsize",
  array(
    '1' => '1',
    '2' => '2',
    '3' => '3',
    '4' => '4',
    '5' => '5',
    '6' => '6'
  )
);
// data for paragraph dropdown list
SpawConfig::setStaticConfigItem("dropdown_data_core_formatBlock",
  array(
    'Normal' => 'Normal',
    '<H1>' => 'Heading 1',
    '<H2>' => 'Heading 2',
    '<H3>' => 'Heading 3',
    '<H4>' => 'Heading 4',
    '<H5>' => 'Heading 5',
    '<H6>' => 'Heading 6'
  )
);
// data for link targets drodown list in hyperlink dialog
SpawConfig::setStaticConfigItem("a_targets",
  array(
    '_self' => 'Self',
    '_blank' => 'Blank',
    '_top' => 'Top',
    '_parent' => 'Parent'
  )
);


// toolbar sets (should start with "toolbarset_"
// standard core toolbars
SpawConfig::setStaticConfigItem('toolbarset_standard',
  array(
    "format" => "format",
    "style" => "style",
    "edit" => "edit",
    "table" => "table",
    "plugins" => "plugins",
    "insert" => "insert",
    "tools" => "tools"
  ) 
);
// all core toolbars
SpawConfig::setStaticConfigItem('toolbarset_all',
  array(
    "format" => "format",
    "style" => "style",
    "edit" => "edit",
    "table" => "table",
    "plugins" => "plugins",
    "insert" => "insert",
    "tools" => "tools",
    "font" => "font"   
  ) 
);
// mini core toolbars
SpawConfig::setStaticConfigItem('toolbarset_mini',
  array(
    "format" => "format_mini",
    "edit" => "edit",
    "tools" => "tools"
  ) 
);
//NV010207
// nukeviet core toolbars
SpawConfig::setStaticConfigItem('toolbarset_nv',
  array(
    "format" => "format",
    "table" => "table",
    "plugins" => "plugins",
    "insert" => "insert",
    "font" => "font"
  ) 
);
//END


// SpawFm plugin config:

// global filemanager settings
SpawConfig::setStaticConfigItem(
  'PG_SPAWFM_SETTINGS',
  array(
    'allow_upload'        => ($editorconfig['allow_upload']) ? true : false,         // allow uploading new files in directory
    'allow_modify'        => ($editorconfig['allow_modify']) ? true : false,         // allow edit filenames/delete files in directory
    'max_upload_filesize' => $editorconfig['max_upload_filesize'],             // max upload file size allowed in bytes, or 0 to ignore
    'max_img_width'       => $editorconfig['max_img_width'],             // max uploaded image width allowed, or 0 to ignore
    'max_img_height'      => $editorconfig['max_img_height'],             // max uploaded image height allowed, or 0 to ignore
    'chmod_to'            => false,         // change the mode of an uploaded file (like to octal 0777 - see PHP chmod() 
                                            // function description for details), or false to leave default
    'allowed_filetypes'   => $editorconfig['allowed_filetypes'],  // allowed filetypes groups/extensions
    'recursive'           => false,         // allow using subdirectories
    'allow_modify_subdirectories' => false,  // allow renaming/deleting subdirectories
    'allow_create_subdirectories' => false,  // allow creating subdirectories
    //'view_mode'           => 'list',      // directory view mode: list/details/thumbnails - TO DO
    //'thumbnails_enabled'  => true,        // enable thumbnails view mode - TO DO
  ),
  SPAW_CFG_TRANSFER_SECURE
);

// directories
	$gf_images = array(
      'dir'     => SpawConfig::getStaticConfigValue('SPAW_UPLOAD').$editorconfig['img_dir'],
      'caption' => 'Images', 
      'params'  => array(
        'default_dir' => true, // set directory as default (optional setting)
        'allowed_filetypes' => array('images')
      )
    );

if($editorconfig['allowed_filetypes']!=array() && in_array("flash",$editorconfig['allowed_filetypes'])) {
$gf_flash = array(
      'dir'     => SpawConfig::getStaticConfigValue('SPAW_UPLOAD').$editorconfig['flash_dir'],
      'caption' => 'Flash movies',
      'params'  => array(
        'allowed_filetypes' => array('flash')
      )
    );
} else {
	$gf_flash = array();
}

if($editorconfig['allowed_filetypes']!=array() && in_array("documents",$editorconfig['allowed_filetypes'])) {
$gf_doc = array(
      'dir'     => SpawConfig::getStaticConfigValue('SPAW_UPLOAD').$editorconfig['doc_dir'],
      'caption' => 'Documents', 
      'params'  => array(
        'allowed_filetypes' => array('documents')
      )
    );
} else {
	$gf_doc = array();
}

if($editorconfig['allowed_filetypes']!=array() && in_array("archives",$editorconfig['allowed_filetypes'])) {
$gf_arch = array(
      'dir'     => SpawConfig::getStaticConfigValue('SPAW_UPLOAD').$editorconfig['arch_dir'],
      'caption' => 'archives', 
      'params'  => array(
        'allowed_filetypes' => array('archives')
      )
    );
} else {
	$gf_arch = array();
}

SpawConfig::setStaticConfigItem(
  'PG_SPAWFM_DIRECTORIES',
  array($gf_images,$gf_flash,$gf_doc,$gf_arch,
  ),
  SPAW_CFG_TRANSFER_SECURE
);

?>
